//计算某字符出现次数

#include <iostream>
#include <string>
using namespace std;

// 我们将字符串与目标字符统一修改为小写
int main() 
{
    string s;
    char target = 0;
    getline(cin, s);
    cin >> target;

    // 1. 改目标字符为小写
    if('A' <= target && target <= 'Z') target += 32;
    // 2. 该字符串为小写并统计目标字符出现的次数
    int count = 0;
    for(auto ch : s)
    {
        if('A' <= ch && ch <= 'Z') ch += 32;
        if(ch == target) count++;
    }
    cout << count << endl;
}